with Pair;
with List;

package body Messages is

   package Lists is new List (Pair.Pair_Type);

   L : Lists.List_Type;

   procedure Add_Message (Key : in String; Msg : in String) is
   begin
      Lists.Append (L, Pair.Create (Key, Msg));
   end Add_Message;

   function Has_Message (Key : in String) return Boolean is
   begin
      for I in 1 .. Lists.Length (L) loop
         if Pair.Key (Lists.Value (L, I)) = Key then
            return True;
         end if;
      end loop;
      return False;
   end Has_Message;

   function Get_Message (Key         : in String;
                         Default_Msg : in String := "") return String is
   begin
      if Has_Message (Key) then
         for I in 1 .. Lists.Length (L) loop
            if Pair.Key (Lists.Value (L, I)) = Key then
               return Pair.Value (Lists.Value (L, I));
            end if;
         end loop;
      end if;
      return Default_Msg;
      end Get_Message;
end Messages;
